<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.lmpop.frame.util.Config"%>
<%@ page import="com.lmpop.createIndex.search.*"%>

<%

	Config conf = new Config();
	conf.init();
	String noimg_path = conf.getString("noimg_path");
	String goods_article_path = conf.getString("goods_article_path");
	AttachIndexFiles attachIndex = new AttachIndexFiles();

	String goods_id = "";
	if(request.getParameter("goods_id")!=null){
		goods_id = request.getParameter("goods_id");
	}
	Cookie cookie = new Cookie("goods"+goods_id, goods_id); 
	cookie.setMaxAge(60*60*24*3);
	cookie.setPath("/");
	response.addCookie(cookie);
	//add cookie


	//get cookie
	Cookie   cookies[]=request.getCookies();
	Cookie   sCookie=null;   
	String   svalue=null;   
	String   sname=null;   
	if(cookies!=null && cookies.length>0){
%>

	document.write('<div class="cont_d_l_nav">');
	document.write('  <p>最近浏览的商品</p>');
    document.write('</div>');

<%
	  int k=0; 
	  for(int a=cookies.length-1;a>= 0;a--){
	    if(cookies[a].getName().startsWith("goods") && !cookies[a].getValue().equals("")){
		    if(k==10)break;
			String name = cookies[a].getName();
			String value = cookies[a].getValue();
			if(value.equals("")){continue;}
			k++;
			GoodsIndexFiles goodsIndex = new GoodsIndexFiles();
			Map goodsMap = goodsIndex.getOneGoods(value,"_allgoods");
			String goods_name="",file_path="",sale_price="",in_date="";
			if(goodsMap.get("goods_name")!=null) goods_name = goodsMap.get("goods_name").toString();
			if(goodsMap.get("sale_price")!=null) sale_price = goodsMap.get("sale_price").toString();
			if(goodsMap.get("in_date")!=null) in_date = goodsMap.get("in_date").toString();
			if(goods_name.length()>15) {
				goods_name = goods_name.substring(0,15);
			}
			file_path = attachIndex.getFilepathById(value);
			if(file_path.equals("")){
				file_path = noimg_path;
			}
			if(in_date.length()>=8){
				String yeard = in_date.substring(0,4);
				String monthd = in_date.substring(4,6);
				String dayd = in_date.substring(6,8);
				in_date = yeard+"-"+monthd+"-"+dayd;
			}
			String infoUrl = goods_article_path + in_date + "/" + value+".html";
%>

	document.write('<div class="hot_cont">');
	document.write('  <div class="hot_cont_l"><a href="<%=infoUrl%>"><img src="<%=file_path%>" width="64" height="59" border="0"/></a></div>');
	document.write('  <div class="hot_cont_r"><p><a href="<%=infoUrl%>"><%=goods_name%></a></p><p class="price">￥<%=sale_price%></p></div>');
    document.write('</div>');


<%
		}
	  }
	}
	

	

%>

	